package org;

import org.acquaintance.I_CRUD;
import org.couchbase.CouchbaseFacade;
import org.mongodb.MongoFacade;
 
public class Driver
{
	private I_CRUD couchbase = new CouchbaseFacade();
	private I_CRUD mongo = new MongoFacade();
	
	private String tinyDoc, smallDoc, largeDoc;
	
	public Driver(){
		Documents doc = new Documents();
		tinyDoc = doc.getTiny();
		smallDoc = doc.getSmall();
		largeDoc = doc.getLarge();
		
	}  

	public static void main(String[] args)
	{
		Driver d = new Driver();
		d.runTest();
    }

	private void create(String attributeName, String attributeValue, int repetitions, String db)
	{
		System.out.println("insert");

		if(db =="Mongo")
			mongo.create(repetitions, attributeName, attributeValue);
		else if (db=="Couchbase")
			couchbase.create(repetitions, attributeName, attributeValue); 
	}
	
	private void read(String db)
	{
		System.out.println("read");
		
		if(db =="Mongo")
			mongo.read();
		else if (db=="Couchbase")
			couchbase.read();
	}
	
	private void update(String attributeName, String attributeValue, String db)
	{
		System.out.println("update");

		if(db =="Mongo")
			mongo.update(attributeName, attributeValue);
		else if (db=="Couchbase")
			couchbase.update(attributeName, attributeValue);
	}
	
	private void delete(String db)
	{
		System.out.println("delete");
		
		if(db =="Mongo")
			mongo.delete();
		else if (db=="Couchbase")
			couchbase.delete();
	}
	
	private void runTest()
	{		
		for (int i = 0; i < 10; i++)
		{
			System.out.println("---------------------------------------------------------------------");
			System.out.println(i);
			System.out.println("---------------------------------------------------------------------");
			/** CREATE */
//			create("text", tinyDoc, todo, "Mongo");
//			create("text", tinyDoc, todo, "Couchbase");
//			create("text", smallDoc, todo, "Mongo");
//			create("text", smallDoc, todo, "Couchbase");
//			create("text", largeDoc, todo, "Mongo");
//			create("text", largeDoc, todo, "Couchbase");
			
			/** READ */
//			read("Couchbase");
//			read("Mongo");
			
			/** UPDATE */
//			update("text1", "This is the update", "Couchbase");
//			update("text1", "This is the update", "Mongo");
			
			/** DELETE */
//			delete("Couchbase");
//			delete("Mongo");
		}
	}
}